<!DOCTYPE html>
<title>A composited child of a perspective sticky element should work correctly</title>
<link rel="help" href="https://www.w3.org/TR/css-position-3/#sticky-pos" />
<meta name="assert" content="This test checks that composited children of perspective sticky elements are positioned correctly." />

<style>
.composited {
  backface-visibility: hidden;
}

.scroller {
  overflow-y: scroll;
  height: 100px;
  /* Making the scroller positioned causes it to contain the absolute marker. */
  position: relative;
}

.sticky {
  position: sticky;
  perspective: 150px;
  top: 0;
  height: 50px;
  width: 50px;
}

.child {
  background: green;
  height: 50px;
  width: 50px;
}

.indicator {
  position: absolute;
  top: 50px;
  height: 50px;
  width: 50px;
  background: red;
}

.padding {
  height: 500px;
}
</style>

<script>
window.addEventListener('load', function() {
  document.querySelector('.scroller').scrollTop = 50;
});
</script>

<div class="composited scroller">
  <div class='indicator'></div>
  <div class="composited sticky">
    <div class="composited child"></div>
  </div>
  <div class="padding"></div>
</div>

<div>You should see one green box above. No red should be visible.</div>
